﻿using SkyWalking.ProductService.Entities;
using SkyWalking.ProductService.Repositorys;
using SkyWalking.ProductService.Services.Dtos;
using Mapster;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;

namespace SkyWalking.ProductService.Services;


[Dependency(ServiceLifetime.Scoped)]
public class ProductService : CrudAppService<Products, ProductDto, Guid>, IProductService
{

    public IProductRepository _repository;

    public ProductService(IProductRepository repository) : base(repository)
    {
        this._repository = repository;
    }

    /// <summary>
    /// 查询商品数据
    /// </summary>
    /// <returns></returns>
    public Task<List<ProductDto>> GetProductsAsync()
    {
        List<Products> products = _repository.GetListAsync().Result;
        var dto = products.Adapt<List<ProductDto>>();
        return Task.FromResult(dto);
    }
}
